#include<bits/stdc++.h>
using namespace std;
typedef struct Node{
	int data;
	struct Node *left;
	struct Node *right;
}NODE,*tree;
int a[100],q1[100],q2[100],t=0;
void swap(tree T){
	tree t=NULL;
	if(T){
		swap(T->left);
		swap(T->right);
		t=T->left;
		T->left=T->right;
		T->right=t;
	}
}
tree insert(tree &T,int x){
	if(!T){
		T=(tree)malloc(sizeof(NODE));
		T->data=x;
		T->left=NULL;
		T->right=NULL;
	}
	else{
		if(x<T->data){
			T->left=insert(T->left,x);
		}
		else if(x>=T->data){
			T->right=insert(T->right,x);
		}
	}
	return T;
}
void pre(tree T){
	if(T){
		q1[t++]=T->data;
		pre(T->left);
		pre(T->right);
	}
}
void post(tree T){
	if(T){
		post(T->left);
		post(T->right);
		q2[t++]=T->data;
	}
}
int main(){
	int n;
	tree T=NULL;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		insert(T,a[i]);
	}
	int flag=0;
	t=0;
	pre(T);
	for(int i=0;i<n;i++){
		if(a[i]!=q1[i]){
			flag++;
			break;
	   }
	}
	if(flag==1){
		swap(T);
		t=0;
		pre(T);
		for(int i=0;i<n;i++){
			if(a[i]!=q1[i]){
				flag++;
				break;
			}
		}
	}
	if(flag==2){
		printf("NO\n");
	}
	else{
		printf("YES\n");
		t=0;
		post(T);
		for(int i=0;i<n;i++){
			printf("%d ",q2[i]);
		}
	}
	return 0;
} 
